package LibraryManagementSystem;

import LibraryManagementSystem.book.Book;
import LibraryManagementSystem.book.Bookcase;
import LibraryManagementSystem.user.AdminUser;
import LibraryManagementSystem.user.NormalUser;
import LibraryManagementSystem.user.User;

import java.util.Scanner;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2022/10/19 21:27
 */
public class Main {
    public static void main(String[] args) {
        Bookcase bookcase = new Bookcase();
        User user = login();
        while (true){
            int choice = user.menu();
            if (choice == -1){
                System.exit(0);
            }
            user.doOperation(choice,bookcase);
        }
    }

    //登录
    public static User login() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您的姓名");
        String name = scanner.nextLine();
        System.out.println("请输入您的身份:1表示普通用户，0表示管理员");
        int who = scanner.nextInt();
        if (who == 1) {
            return new NormalUser(name);
        } else if (who == 0) {
            return new AdminUser(name);
        }else {
            System.out.println("输入不合法 ！");
        }
        return null;
    }
}
